package com.top.ruizhong.main.host

import android.app.Activity
import android.content.Intent
import android.graphics.Color
import com.blankj.utilcode.util.ColorUtils
import com.blankj.utilcode.util.LogUtils
import com.github.mikephil.charting.components.XAxis
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter
import com.module.lemlin.base.BaseAbstractActivity
import com.top.ruizhong.R
import kotlinx.android.synthetic.main.activity_main_overview.*


class MainOverviewActivity : BaseAbstractActivity() {

    companion object {
        fun open(activity: Activity) {
            val intent = Intent(activity, MainOverviewActivity::class.java)
            activity.startActivity(intent)
        }
    }

    override val layoutResId: Int
        get() = R.layout.activity_main_overview

    override fun stateBar(): StatusBar {
        return StatusBar(isLightMode = false, view = flOverviewBar)
    }

    override fun initView() {

        ivOverviewBack.setOnClickListener { this.finish() }

        lineChart.xAxis.position = XAxis.XAxisPosition.BOTTOM
//        lineChart.axisLeft.axisMinimum = 0f
//        lineChart.axisRight.axisMinimum = 0f

//        lineChart.xAxis.axisLineColor = ColorUtils.getColor(R.color.FF_CCCCCC)
//        lineChart.axisLeft.axisLineColor = ColorUtils.getColor(R.color.FF_CCCCCC)


        lineChart.setBackgroundColor(Color.WHITE)
        lineChart.setDrawBorders(false)

        lineChart.setDrawGridBackground(false)

        lineChart.xAxis.setDrawGridLines(false)
        lineChart.axisRight.setDrawGridLines(false)

        lineChart.axisRight.isEnabled = false

        //隐藏描述
        lineChart.description.isEnabled = false
        //隐藏标签
        lineChart.legend.isEnabled = false

        lineChart.xAxis.valueFormatter = object :IndexAxisValueFormatter(){
            override fun getFormattedValue(value: Float): String {
                return "01-18"
            }
        }


        val entry: MutableList<Entry> = mutableListOf(
            Entry(5f, 0f),
            Entry(10f, 3f),
            Entry(15f, 10f),
            Entry(20f, 6f),
            Entry(25f, 15f),
            Entry(30f, 12f),
            Entry(35f, 8f)
        )
        val data = LineDataSet(entry,"")

        data.lineWidth = 2f
        data.color = ColorUtils.getColor(R.color.colorMain)
        data.setCircleColor(ColorUtils.getColor(R.color.colorMain))
        data.setDrawCircleHole(false)
        data.setDrawValues(false)

        lineChart.data = LineData(data)

    }
}